# Contributor: Ian Douglas Scott <ian@iandouglasscott.com>
# Maintainer: Ian Douglas Scott <ian@iandouglasscott.com>
pkgname=wabt
pkgver=1.0.19
pkgrel=0
pkgdesc="WebAssembly binary toolkit"
arch="all"
url="https://github.com/WebAssembly/wabt"
license="Apache-2.0"
makedepends="cmake"
subpackages="$pkgname-doc"
_wasm_c_api_commit="d9a80099d496b5cdba6f3fe8fc77586e0e505ddc"
source="$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz
	wasm-c-api-$_wasm_c_api_commit.tar.gz::https://github.com/WebAssembly/wasm-c-api/archive/$_wasm_c_api_commit.tar.gz
	"
# Tests require vendored dependencies (as git submodules). Should be modified
# to use copies from repository.
options="!check"

build() {
	# https://github.com/WebAssembly/wabt/issues/1315
	rmdir third_party/wasm-c-api
	ln -s ../../wasm-c-api-$_wasm_c_api_commit third_party/wasm-c-api

	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake  -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_TESTS=OFF \
		-DBUILD_TESTS=OFF \
		$CMAKE_CROSSOPTS
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="cddcd598f1c7ccf87b1efed685571958f4169c07c10a1a7e62a69bd111debe6c6d20702b91a1206fe1aba9ff78d920b9284564f4d796a3583b474e8cfa4d141b  wabt-1.0.19.tar.gz
b6ee7d2d83a3ca7b3cb3ee110282f7d32eada1d9020cadd3fdec58f40478879fd9ac9fada526021d8f6e8a26e1df7353df313d4149be2ffe4aea3a28f856fd89  wasm-c-api-d9a80099d496b5cdba6f3fe8fc77586e0e505ddc.tar.gz"
